/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.mcx.modules.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author mcx
* @date 2022-03-22
**/
@Entity
@Data
@Table(name="role")
public class Role implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "编号")
    private Integer id;

    @Column(name = "status",nullable = false)
    @NotNull
    @ApiModelProperty(value = "状态")
    private Integer status;

    @Column(name = "player_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "所属账号Id")
    private Integer playerId;

    @Column(name = "role_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "角色Id")
    private Integer roleId;

    @Column(name = "name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "昵称")
    private String name;

    @Column(name = "sex")
    @ApiModelProperty(value = "性别")
    private Integer sex;

    @Column(name = "level")
    @ApiModelProperty(value = "等级")
    private Integer level;

    @Column(name = "exp")
    @ApiModelProperty(value = "经验")
    private Integer exp;

    @Column(name = "max_hp")
    @ApiModelProperty(value = "最大生命")
    private Integer maxHp;

    @Column(name = "max_mp")
    @ApiModelProperty(value = "最大法力")
    private Integer maxMp;

    @Column(name = "curr_hp")
    @ApiModelProperty(value = "当前生命")
    private Integer currHp;

    @Column(name = "curr_mp")
    @ApiModelProperty(value = "当前法力")
    private Integer currMp;

    @Column(name = "attack")
    @ApiModelProperty(value = "攻击力")
    private Integer attack;

    @Column(name = "defense")
    @ApiModelProperty(value = "防御力")
    private Integer defense;

    @Column(name = "cri")
    @ApiModelProperty(value = "暴击")
    private String cri;

    @Column(name = "vio_injury")
    @ApiModelProperty(value = "暴击伤害")
    private String vioInjury;

    @Column(name = "res")
    @ApiModelProperty(value = "抗性")
    private Integer res;

    @Column(name = "createtime",nullable = false)
    @NotNull
    @CreationTimestamp
    @ApiModelProperty(value = "创建时间")
    private Timestamp createtime;

    @Column(name = "updatetime")
    @UpdateTimestamp
    @ApiModelProperty(value = "更新时间")
    private Timestamp updatetime;

    public void copy(Role source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}